#include "selectstaff.h"
#include "ui_selectstaff.h"
#include "myprotocol.h"

SelectStaff::SelectStaff(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::SelectStaff)
{
    ui->setupUi(this);
    this->setFixedSize(this->size().width(),this->size().height());
    this->setWindowIcon(QIcon(":/new/prefix1/Image/mesage.png"));
    this->setWindowTitle("STAFF INFO");
    QPalette qp = this->palette(); //重新拷贝一份和本对象palette相同的palette
    qp.setBrush(QPalette::Window,QBrush(QImage(":/new/prefix1/Image/Frame.jpg").scaled(this->size())));
    this->setPalette(qp);

    this->ui->pic->setPixmap(QPixmap(":/new/prefix1/Image/write2file.png"));

    connect(this,&SelectStaff::my_select_signal,this,&SelectStaff::my_select_slot);
}

SelectStaff::~SelectStaff()
{
    delete ui;
}

void SelectStaff::set_socket(QTcpSocket *socket)
{
    this->socket = socket;
}

void SelectStaff::my_select_slot(QStringList strlist)
{
    this->ui->textEdit->clear();
    this->ui->textEdit->setReadOnly(true);
    int i = 1;
    QString temp;
    for(QString str : strlist)
    {
        temp += str;
        if(i % 4 == 0)
        {
            this->ui->textEdit->append(temp);
            temp.clear();
        }
        else
        {
            temp += " ; ";
        }
        i++;
    }

}

void SelectStaff::on_back_btn_clicked()
{
    emit this->my_back_to_hrORmanagerop_signal();
    this->hide();
    this->ui->textEdit->clear();
}
